<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>评教管理系统-个人信息</title>
</head>
<link th:href="@{/plugin/layui/css/layui.css}" rel="stylesheet"/>
<script type="text/javascript" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <input type="hidden" name="id" id="id" autocomplete="off"  class="layui-input">
        <div class="layui-input-block" style="width: 300px;">
            <input type="text" name="username" id="username" disabled lay-verify="title" autocomplete="off" placeholder="请输入用户名"
                    class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密 码</label>
        <div class="layui-input-block" style="width: 300px;">
            <input type="password" name="password" id="password" lay-verify="title" autocomplete="off" placeholder="请输入密码"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="saveOrAdd">修改密码</button>
        </div>
    </div>
</form>
</body>
<script>
    layui.use(['form', 'layer', 'table'], function () {
        var table = layui.table
            , form = layui.form, $ = layui.$;
        $.post("course/getLoginUser", function (msg) {
            //var msg = JSON.stringify(data);
            $("#id").val(msg.id);
            $("#username").val(msg.username);
            $("#password").val(msg.password);
        });

        //监听编辑或者添加
        form.on('submit(saveOrAdd)', function (data) {
            var url = "course/updateLoginUser";
            var datas = data.field;
            $.ajax({
                url: url,
                data: JSON.stringify(datas),
                type: "POST",
                dataType: "json",
                contentType: "application/json;charset=UTF-8",
                success: function (result) {
                    if(result.code=="100"){
                        layer.msg(result.message, {icon: 6});
                        setTimeout(function () {
                            window.parent.location.reload();
                        }, 2000);
                    }
                     else {
                        layer.msg(result.message, {icon: 5});
                    }
                },
                error: function (error) {
                    layer.msg('系统异常！请联系管理员', {icon: 5});
                }
            });
            return false;
        });
    });
</script>
</html>